const arr = ["[", "[", "{", "]", "}", "]", "}"];
const arr1 = ["[", "[", "{", "}", "]", "]"];

function matchBracket(arr) {
  const leftMap = ["{", "[", "<", "《", "("],
    rightMap = ["}", "]", ">", "》", ")"];
  const map = [];
  arr.forEach((item) => {
    const index = leftMap.findIndex((i) => item === i);
    if (index > -1) {
      map.push(item);
    } else {
      const latest = map[map.length - 1];
      if (
        rightMap.findIndex((i) => i === item) ===
        leftMap.findIndex((i) => i === latest)
      ) {
        map.pop();
      } else {
        map.push(item);
      }
    }
    console.log(map);
  });
  return map.length === 0;
}

// console.log(matchBracket(arr));
console.log(matchBracket(arr1));
